//
//  txlxqViewController.m
//  PASystem
//
//  Created by michael on 16/10/9.
//  Copyright © 2016年 czd. All rights reserved.
//

#import "txlxqViewController.h"

@interface txlxqViewController ()
@property(nonatomic,strong)NSMutableArray * dataArray;

@property(nonatomic,strong)NSDictionary * dic;

@end

@implementation txlxqViewController

- (void)viewDidLoad {
    [super viewDidLoad];
self.view.backgroundColor  = [UIColor  whiteColor];
view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight-64-46)];
     UIColor *myColor = [UIColor colorWithWhite:0.8 alpha:0.3];
view.backgroundColor = myColor;
[self.view addSubview:view];
         self.title = _string;
[self request];
  
}
- (void)request{
    NSString * userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userId"];
    NSString * pwdId = [[NSUserDefaults standardUserDefaults]objectForKey:@"pwdId"];
    NSString * userHumber = [[NSUserDefaults standardUserDefaults]objectForKey:@"userHumber"];
    
 NSString *json =[NSString stringWithFormat: @"{'action':wdllzMch,'service':UserService, 'userName':'%@','password':'%@','vaueJson':'{userid :%@,id:%@}'}",userId,pwdId,userHumber,_id];
     NSArray * array = @[@{@"arg0":json}];
    [HttpTools requestWithURL:BaseURL arrays:array method:Basemethod success:^(id JSON) {

       
     NSDictionary *dic = JSON[@"reason"];
        
    NSDictionary *dict = dic[@"attrs"];
//    NSLog(@"%@",dict);
    
    _dic = dict;
    [_dataArray addObject:dict];
    

//     NSLog(@"11%@",_dataArray);
        
[self initview];
    } failure:^(NSError *error) {
        
    }];
 
}
- (void)initview
{
_tableView = [[UITableView alloc]initWithFrame:CGRectMake(10, 10, KScreenWidth-20, view.height-20) style:UITableViewStylePlain];
     self.tableView.bounces = NO;
_tableView.dataSource = self;
_tableView.delegate =self;
[view addSubview:_tableView];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

if (indexPath.row ==0) {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, cell.contentView.height)];
    label.text = @"姓名:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top, view.width  -100, label.height)];
    label2.text = _dic[@"NAME"];
    label2.textAlignment = NSTextAlignmentRight;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}else if (indexPath.row ==1){
 UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, cell.contentView.height)];
    label.text = @"类别:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top, view.width  -100, label.height)];
  NSString *string = [NSString stringWithFormat:@"%@",_dic[@"TYPE"]];
  if ([string isEqualToString:@"1"]){
      label2.text = @"海外联络处";
  } if ([string isEqualToString:@"2"]){
      label2.text = @"境内机构";
  }if ([string isEqualToString:@"3"]){
      label2.text = @"签约机构";
  }if ([string isEqualToString:@"4"]){
      label2.text = @"境外商协会";
  }
    label2.textAlignment = NSTextAlignmentRight;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;



}else if (indexPath.row ==2){
 UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, cell.contentView.height)];
    label.text = @"单位:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top, view.width  -100, label.height)];
    label2.text = _dic[@"COMPANY"];
    label2.textAlignment = NSTextAlignmentRight;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}
else if (indexPath.row ==3){
 UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, cell.contentView.height)];
    label.text = @"职务:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top, view.width  -100, label.height)];
    label2.text = _dic[@"JOB"];
    label2.textAlignment = NSTextAlignmentRight;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}
else if (indexPath.row ==4){
 UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, cell.contentView.height)];
    label.text = @"地址:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top, view.width  -100, label.height)];
    label2.text = _dic[@"ADDRESS"];
    label2.textAlignment = NSTextAlignmentRight;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}
else if (indexPath.row ==5){
 UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, cell.contentView.height)];
    label.text = @"E-mail:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top, view.width  -100, label.height)];
    label2.text = _dic[@"EMAIL"];
    label2.textAlignment = NSTextAlignmentRight;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}
else if (indexPath.row ==6){
 UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, cell.contentView.height)];
    label.text = @"电话:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top, view.width  -100, label.height)];
    label2.text = _dic[@"TEL"];
    label2.textAlignment = NSTextAlignmentRight;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}
else if (indexPath.row ==7){
 UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, cell.contentView.height)];
    label.text = @"传真:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top, view.width  -100, label.height)];
    label2.text = _dic[@"FOX"];
    label2.textAlignment = NSTextAlignmentRight;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}
else if (indexPath.row ==8){
 UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, cell.contentView.height)];
    label.text = @"手机:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top, view.width  -100, label.height)];
    label2.text = _dic[@"PHONE"];
    label2.textAlignment = NSTextAlignmentRight;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}

else if (indexPath.row ==9){
 UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, cell.contentView.height)];
    label.text = @"网址:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top, view.width  -100, label.height)];
    label2.text = _dic[@"WEB"];
    label2.textAlignment = NSTextAlignmentRight;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}
else if (indexPath.row ==10){
 UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, cell.contentView.height)];
    label.text = @"来源:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
         CGFloat titleSize = [OAToolBox sizebyText:_dic[@"SOURCE"] font:12 minsWidth:120];
  if (titleSize<44) {
    titleSize =  cell.height;
}else{
titleSize = titleSize;

}

  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top, view.width  -100, titleSize)];
    label2.text = _dic[@"SOURCE"];
    label2.textAlignment = NSTextAlignmentRight;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}
else if (indexPath.row ==11){
 UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, cell.contentView.height)];
    label.text = @"团组:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  CGFloat titleSize = [OAToolBox sizebyText:_dic[@"GROUPS"] font:12 minsWidth:120];
  if (titleSize<44) {
    titleSize =  cell.height;
}else{
titleSize = titleSize;

}

  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top, view.width  -100, titleSize)];
    label2.text = _dic[@"GROUPS"];
    label2.textAlignment = NSTextAlignmentRight;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}
else if (indexPath.row ==12){
 UITableViewCell* cell = [[UITableViewCell alloc]init];
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, cell.contentView.height)];
    label.text = @"备注:";
     label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
  CGFloat titleSize = [OAToolBox sizebyText:_dic[@"REMARKS"] font:12 minsWidth:120];
  if (titleSize<44) {
    titleSize =  cell.height;
}else{
titleSize = titleSize;

}

  UILabel *label2= [[UILabel alloc]initWithFrame:CGRectMake(label.right, label.top, view.width  -100, titleSize)];
     label2.text = _dic[@"REMARKS"];
    label2.textAlignment = NSTextAlignmentRight;
     label2.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:label2];
    return cell;

}else{
UITableViewCell* cell = [[UITableViewCell alloc]init];
      image1 = [[WBImageView alloc]initWithFrame:CGRectMake(10, 10, (_tableView.width-30)/2, 100)];
    image2 = [[WBImageView alloc]initWithFrame:CGRectMake(image1.right+10, 10, (_tableView.width-30)/2, 100)];
    NSString *string1 = [NSString stringWithFormat:@"%@%@",web1,_dic[@"POSITIVE"]];
        NSString *string2 = [NSString stringWithFormat:@"%@%@",web1,_dic[@"OPPOSITE"]];
          NSURL *imageUrl1 = [NSURL URLWithString:string1];
[image1 sd_setImageWithURL:imageUrl1 placeholderImage:nil];
image1.originalImageUrl = string1;
  NSURL *imageUrl2= [NSURL URLWithString:string2];
    [image2 sd_setImageWithURL:imageUrl2 placeholderImage:nil];

//  _scrollview1=[[UIScrollView alloc]initWithFrame:image1.bounds];
// [cell.contentView addSubview:_scrollview1];
//[_scrollview1 addSubview:image1];
// _scrollview1.delegate=self;
//_scrollview1.contentSize = image1.size;
//_scrollview1.maximumZoomScale = 2;
//_scrollview1.minimumZoomScale = 0.5;
//    [cell.contentView addSubview:_scrollview1];
    [cell.contentView addSubview:image1];
    [cell.contentView addSubview:image2];
       return cell;

}

}
 -(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
 {
    return image1;
 }
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CGFloat H = 44;
if (indexPath.row == 11){
 CGFloat titleSize = [OAToolBox sizebyText:_dic[@"SOURCE"] font:12 minsWidth:120];
if (titleSize<44) {
    return 44;
}else{
return titleSize;

}
}

else if (indexPath.row ==11){
 CGFloat titleSize = [OAToolBox sizebyText:_dic[@"GROUPS"] font:12 minsWidth: 120];
if (titleSize<44) {
    return 44;
}else{
return titleSize;

}
}else if (indexPath.row ==12){
 CGFloat titleSize = [OAToolBox sizebyText:_dic[@"REMARKS"] font:12 minsWidth: 120];
if (titleSize<44) {
    return 44;
}else{
return titleSize;

}
}
else if (indexPath.row ==13){
return 120;

}
else{

return H;
}

}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return  14;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
